/*
 * @Description: 回收站相关接口
 * @Author: Rfan
 * @Date: 2022-10-31 17:56:05
 * @LastEditTime: 2022-10-31 17:56:05
 */

import request from '@/utils/request';
import { Key } from 'react';
import { ICommonParams, IPageQuery } from '@/interfaces/global';
import { IArchiveBox } from '@/interfaces/box';

export interface IBoxItemParams {
  commonParams: ICommonParams;
  dirTreeId: number;
}

// 分页获取盒列表
export function fetchBoxListByPage(data: IPageQuery<IBoxItemParams>) {
  return request({
    url: `/view-archive-box/page-box`,
    method: 'post',
    data
  });
}

// 获取盒内文件
export function fetchFileInBox(data: IPageQuery<{ archiveBoxId: number }>) {
  return request({
    url: `/view-archive-box/page-file`,
    method: 'post',
    data
  });
}

export interface IEditBoxParams extends IBoxItemParams {
  id: number;
}

// 新增盒
export function addBox(data: IEditBoxParams) {
  return request({
    url: `/archive-box/`,
    method: 'post',
    data
  });
}

// 编辑增盒
export function editBox(data: IBoxItemParams) {
  return request({
    url: `/archive-box/`,
    method: 'put',
    data
  });
}

// 删除盒
export function deleteBox(id: Key) {
  return request({
    url: `/archive-box/${id}`,
    method: 'delete'
  });
}

export interface IPackBoxParams {
  archiveBox: IArchiveBox;
  archiveTypeId: number;
  commonParams: ICommonParams;
  entryIdList: number[];
  level: number;
}
// 分盒、装盒
export function packBoxMethod(data: IPackBoxParams[]) {
  return request({
    url: `/archive-arrangement/box-pack`,
    method: 'post',
    data
  });
}

export interface IUnpackBoxParams {
  archiveTypeId: number;
  commonParams: ICommonParams;
  entryIdList: number[];
  level: number;
}
// 拆盒
export function unpackBoxMethod(data: IUnpackBoxParams) {
  return request({
    url: `/archive-arrangement/box-unpack`,
    method: 'post',
    data
  });
}
